<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style lang="">
        body{
            background: #000;
            text-align: center;
        }
        #c1{
            background: #fff;
        }
    </style>
</head>
<body>
    <canvas id="c1" width="800" height="600"></canvas>    
</body>
<script>
    //角度转弧度
    function d2a(n){
        return n*Math.PI/180
    }
    function a2d(n){
        return n*180/Math.PI
    }


    let oC=document.getElementById('c1');
    let gd=oC.getContext('2d');
    let cx = 400, cy = 300, r = 150;
    

    function pie(startAng,endAng,color){
        gd.beginPath();
        gd.moveTo(cx, cy);
        let x=cx+Math.sin(d2a(startAng))*r
        let y=cy-Math.cos(d2a(startAng))*r
        gd.lineTo(x, y);
        gd.arc(cx,cy,r,d2a(startAng-90),d2a(endAng-90),false)
        gd.closePath()
        gd.fill()
    }

    pie(0,20,'ddd')




</script>

</html>